import { Sendcontroller } from '../lib/sendController';
const sendcontroller = new Sendcontroller();
let interval = 30,                                                //间隔时间(s)
    time;                                                         //开关
function heart_check(id, all) {
    time = setInterval(() => {
        var msg = sendcontroller.pushMessage("heartbeat", {}, id, all)      //发送消息
        sendcontroller.sendMessage(msg.data.data.head.clientMsgId);
    }, interval * 1000);
}
/*开始心跳检测*/
export function start(id, all) {
    if (!time) {
        // console.log("start！")
        heart_check(id, all)
    }
}
/*停止心跳检测*/
export function stop() {
    if (time) {
        // console.log("stop！");
        clearInterval(time);
        time = '';
    }
}